package com.qiangesoft.cloud.provider.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.stereotype.Service;

@Service
public class PaymentService {

    @HystrixCommand(fallbackMethod = "addHystrixFail", commandProperties = {@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")})
    public String addHystrix(String name) {
        int a = 5 / 0;
//        try {
//            Thread.sleep(10000L);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        return name + ":" + Thread.currentThread().getName();
    }

    public String addHystrixFail(String name) {
        return Thread.currentThread().getName() + " 系统繁忙，请稍后再试！";
    }
}
